package Hot100;

public class 移动零_283 {
    public void moveZeroes(int[] nums) {
        int n = nums.length;
        int a = 0;
        for (int b = 0; b < n; b++) {
            if (nums[b] != 0) {
                // 交换非零元素和零元素的位置
                int tmp = nums[a];
                nums[a] = nums[b];
                nums[b] = tmp;
                a++; // 保证a对应的每次都是0
            }
        }
    }
}
